STEP 17: We need to change the rotation for each sprite. We can do this while looping through our sprite list.
Click on the LOGIC tab, then click on .
Drag out Add Value to the bottom of your code, inside the loop.
Change my_var to rotate and change 1 to 30 .
Each time the loop runs, rotate increases by 30, which causes the next sprite to rotate further around the world.
To navigate the page using the TAB key, first press ESC to exit the code editor.
stage.set_background_color("lightblue")
# sprite = codesters.Rectangle(x, y, width, height, "color")
sprite = codesters.Rectangle(0, 0, 700, 100, "gold")
sprite.turn_left(45)
# sprite = codesters.Rectangle(x, y, width, height, "color")
sprite = codesters.Rectangle(0, 0, 700, 100, "gold")
sprite.turn_right(45)
sprite = codesters.Sprite("earth")
people_sprites = ['person1', 'person2', 'person3', 'person4', 'person5', 'person6',
'person7', 'person8','person9', 'person10', 'person11', 'person12']
rotate = 90
for value in people_sprites:
# add code here
sprite = codesters.Sprite(value)
stage.wait(0.5)
sprite.set_size(0.3)
sprite.set_speed(5)
sprite.move_forward(120)
sprite.turn_right(90)
sprite.rotate_origin(rotate)
t = codesters.Teacher()
try:
tval1 = rotate
except:
tval1 = "DNE"
try:
params = t.find_text("+=")
tval2 = params[0][1]
tval2a = t.get_indent_at_line(params[0][0])
except:
tval2 = "DNE"
tval2a = "DNE"
print(tval1)
print(params)
print(tval2)
print(tval2a)
t1 = TestObjective()
t1.add_success('30' in tval2, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you delete your variable rotate?")
t1.add_failure(tval2 == "DNE" or tval2 == [], "Did you use += to add 30 to rotate?")
t1.add_failure(tval2a != 4, "Did you indent rotate += 30 inside the loop?")
t1.add_failure('1' in tval2, "Did you add 30 to rotate?")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
Run Code
Activity Submitted!
Submit Work
Next Activity
Stop Running Code
Show Chart
Show Console
Reset Code Editor
Codesters How To (opens in a new tab)